﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="AdminUsers.aspx.cs" Inherits="VO.Web.Account.AdminUsers" %>

<%@ MasterType VirtualPath="~/Site.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Users admin
    </h2>
    <p>
        <asp:UpdatePanel ID="pnlUsers" runat="server" UpdateMode="Always">
            <ContentTemplate>
                <asp:GridView ID="gvUsers" runat="server" AutoGenerateColumns="False" DataKeyNames="ProviderUserKey"
                    DataSourceID="odsUsers" OnRowCommand="gvUsers_RowCommand">
                    <Columns>
                        <asp:BoundField DataField="ProviderUserKey" HeaderText="ProviderUserKey" Visible="False" />
                        <asp:BoundField DataField="UserName" HeaderText="UserName" ReadOnly="True" SortExpression="UserName" />
                        <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                        <asp:BoundField DataField="PasswordQuestion" HeaderText="PasswordQuestion" ReadOnly="True"
                            SortExpression="PasswordQuestion" Visible="False" />
                        <asp:BoundField DataField="Comment" HeaderText="Comment" SortExpression="Comment"
                            Visible="False" />
                        <asp:CheckBoxField DataField="IsApproved" HeaderText="IsApproved" SortExpression="IsApproved">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:CheckBoxField>
                        <asp:TemplateField HeaderText="Locked" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:ImageButton ID="btnUnlock" runat="server" ImageUrl="~/images/icon-unlock-color-16.png"
                                    CommandName="Unlock" CommandArgument='<%# Eval("ProviderUserKey") %>' Visible='<%# (bool)Eval("IsLockedOut") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="LastLockoutDate" DataFormatString="{0: dd/MM/yyyy}" HeaderText="LastLockoutDate"
                            ReadOnly="True" SortExpression="LastLockoutDate">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="CreationDate" DataFormatString="{0: dd/MM/yyyy}" HeaderText="CreationDate"
                            ReadOnly="True" SortExpression="CreationDate">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="LastLoginDate" DataFormatString="{0: dd/MM/yyyy}" HeaderText="LastLoginDate"
                            SortExpression="LastLoginDate">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="LastActivityDate" DataFormatString="{0: dd/MM/yyyy}" HeaderText="LastActivityDate"
                            SortExpression="LastActivityDate">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="LastPasswordChangedDate" DataFormatString="{0: dd/MM/yyyy}"
                            HeaderText="PassChangedDate" ReadOnly="True" SortExpression="LastPasswordChangedDate">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:CheckBoxField DataField="IsOnline" HeaderText="IsOnline" ReadOnly="True" SortExpression="IsOnline">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:CheckBoxField>
                        <asp:TemplateField HeaderText="Admin" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:ImageButton ID="btnChnageAdmin" runat="server" ImageUrl='<%# GetIsAdmin(Eval("ProviderUserKey").ToString()) ? "~/images/icon-unpromote-user-16.png" : "~/images/icon-promote-user-16.png"  %>'
                                    ToolTip='<%# GetIsAdmin(Eval("ProviderUserKey").ToString()) ? "Unpromote to user" : "Promote to admin"  %>'
                                    CommandName="ChangeAdmin" CommandArgument='<%# Eval("ProviderUserKey") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="ProviderName" HeaderText="ProviderName" ReadOnly="True"
                            SortExpression="ProviderName" Visible="False" />
                    </Columns>
                </asp:GridView>
                <asp:ObjectDataSource ID="odsUsers" runat="server" SelectMethod="GetMembershipUsers"
                    TypeName="VO.Web.Controllers.MembershipController"></asp:ObjectDataSource>
            </ContentTemplate>
        </asp:UpdatePanel>
    </p>
</asp:Content>
